package com.example.administrator.leargit.activity;

import android.content.Intent;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.example.administrator.leargit.R;
import com.example.administrator.leargit.fragment.Basefragment;

public class MainActivity extends BaseActivity {


    private int selected_tab = 0;
    private Basefragment mCurrentFragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setLock(true);
        setContentView(R.layout.activity_main);
        Intent intent = getIntent();
        if (savedInstanceState != null) {
            selected_tab = savedInstanceState.getInt("selected_tab");
        }
        initView();
        action(getIntent());
    }

    private void action(Intent intent) {

    }

    private void initView() {

    }

    public void switchTabHost(int position) {


        FragmentTransaction transaction = fragmentManager.beginTransaction();
        hideAllFragment(transaction);
        switch (position) {
            case 1:
                /*transaction.add(0,)
                mCurrentFragment=  */
                break;
            case 2:
                break;
            case 3:
                break;

        }
    }

    private void hideAllFragment(FragmentTransaction transaction) {
        if (mCurrentFragment != null) {
            transaction.hide(mCurrentFragment);
        }

    }

    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        outState.putInt("selected_tab", selected_tab);
    }
}
